<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <title>Document</title>
</head>
<body>
    <div id="root">
    </div>

    <script>

        // 定义全局组件
        const hello = Vue.extend({
            template: `<h3>{{name}}</h3>`,
            data() {
                return {
                    name: 'hello'
                }
            }
        })

        // 第一步：定义组件
        const student = Vue.extend({
            template: `
                <div>
                    <h2>{{studentName}}</h2>
                    <h2>{{studentAge}}</h2>
                </div>
            `,
            data() {
                return {
                    studentName: 'zoe',
                    studentAge: '18',
                }
            }
        })
        const school = Vue.extend({
            template: `
                <div>
                    <h2>{{schoolName}}</h2>
                    <h2>{{schoolAddress}}</h2>
                    <student></student>
                </div>
            `,
            data() {
                return {
                    schoolName: '尚硅谷',
                    schoolAddress: 'bejing',
                }
            },
            components: {
                student,
            }
        })

        const app = Vue.extend({
            template: `
                <div>
                    <hello></hello>
                    <school></school>
                </div>
            `,
            components: {
                hello,
                school,
            }
        })

        new Vue({
            el: '#root',
            template: `<app></app>`,
            components: { app }
        })
    </script>
</body>
</html>